// pages/visitorInformation/index.ts
Page({
  /**
   * 页面的初始数据
   */
  data: {
    adultList: [],
    underList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async onShow() {
    try {
      const res = await getApp().request({
        path: "/s/v/listVisitors",
        method: "GET",
      });
      const adult = res.filter((item: any) => item.typeStr === "adult");
      const underlt = res.filter((item: any) => item.typeStr === "child");
      this.setData({
        adultList: adult,
        underList: underlt,
      });
    } catch {}
  },
  handleAdult() {
    wx.navigateTo({
      url: "/pages/adultForm/index",
    });
  },
  handleEditAdult(e) {
    const { id } = e.target.dataset;
    wx.navigateTo({
      url: `/pages/adultForm/index?id=${id}`,
    });
  },
  handleUnder() {
    wx.navigateTo({
      url: "/pages/underForm/index",
    });
  },
  handleEditUnder(e) {
    const { id } = e.target.dataset;
    wx.navigateTo({
      url: `/pages/underForm/index?id=${id}`,
    });
  },
});
